package com.ecable.action;

import java.io.IOException;
import java.io.PrintWriter;

import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import com.ecable.daoImpl.ProfileDAO;
import com.ecable.util.UtilConstants;

public class DeleteCustomerStatusAction extends HttpServlet {

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;

	public void doGet(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {

		doPost(request, response);
	}

	public void doPost(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
			String path="";
			boolean flag=false;
		HttpSession session = request.getSession();
		int userid = Integer.parseInt(request.getParameter("userid"));
		System.out.println("userid :" + userid);
		try {
		
			flag = new ProfileDAO().updateCustomerStatus(userid);
			System.out.println(flag);
			if (flag) {

				request.setAttribute("status1", UtilConstants._USER_STATUS_DELETE);
				path = UtilConstants._DISPLAY_OPERATOR_ACTION;

			}  else {

				request.setAttribute("status", UtilConstants._USER_STATUS_DELETE_FAIL);
				path = UtilConstants._DISPLAY_OPERATOR_ACTION;
				
			}

		} catch (Exception e) {

			request.setAttribute("status", UtilConstants._USER_STATUS_DELETE_FAIL);
			path = UtilConstants._DISPLAY_OPERATOR_ACTION;

		}
		RequestDispatcher rd = request.getRequestDispatcher(path);

		rd.forward(request, response);
	}

}
